]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
get_app_for_window_direct search ShellApp by window, before create.
authorMaxim Ermilov <zaspire@rambler.ru>
Sun, 21 Feb 2010 00:16:30 +0000 (03:16 +0300)
committerMaxim Ermilov <zaspire@rambler.ru>
Sun, 21 Feb 2010 00:19:24 +0000 (03:19 +0300)
https://bugzilla.gnome.org/show_bug.cgi?id=610324

src/shell-app-system.c
src/shell-app-system.h
src/shell-window-tracker.c

index 4b57e8a4a849a0a935ab9607a88d5090c7f5bfc7..4d8b7c809c496e321efc9800f974794005bf4b5d 100644 (file)
@@ -484,6 +484,32 @@ shell_app_system_get_app (ShellAppSystem   *self,
   return app;
 }
 
+/**
+ * shell_app_system_get_app_for_window:
+ * @self: A #ShellAppSystem
+ * @window: A #MetaWindow
+ *
+ * Find or create a #ShellApp for window
+ *
+ * Return value: (transfer full): The #ShellApp for window, or %NULL if none
+ */
+ShellApp *
+shell_app_system_get_app_for_window (ShellAppSystem *self,
+                                     MetaWindow *window)
+{
+  char *id = g_strdup_printf ("window:%p", window);
+  ShellApp *app = g_hash_table_lookup (self->priv->app_id_to_app, id);
+
+  if (app)
+    g_object_ref (G_OBJECT (app));
+  else
+    app = _shell_app_new_for_window (window);
+
+  g_free (id);
+
+  return app;
+}
+
 /* ShellAppSystem ensures we have a unique instance of
  * apps per id.
  */
index d6c75817cb2eb2592930c1bbb1cff2417434b957..a02cfb7c5ed07484cac3d70ba5022a11f8dfd158 100644 (file)
@@ -66,6 +66,7 @@ gboolean shell_app_info_launch (ShellAppInfo *info,
 ShellAppInfo *shell_app_system_load_from_desktop_file (ShellAppSystem *system, const char *filename, GError **error);
 
 ShellApp *shell_app_system_get_app (ShellAppSystem *system, const char *id);
+ShellApp *shell_app_system_get_app_for_window (ShellAppSystem *self, MetaWindow *window);
 
 void _shell_app_system_register_app (ShellAppSystem *self, ShellApp *app);
 
index 0865b2b864968c6fbb9ec72f73448368d77c36f7..bf76488817b23b19f00f8b8cf8d066016a8c7c7b 100644 (file)
@@ -302,15 +302,15 @@ get_app_for_window_direct (MetaWindow  *window)
   char *wmclass;
   char *with_desktop;
 
+  appsys = shell_app_system_get_default ();
   wmclass = get_appid_from_window (window);
 
   if (!wmclass)
-    return _shell_app_new_for_window (window);
+    return shell_app_system_get_app_for_window (appsys, window);
 
   with_desktop = g_strjoin (NULL, wmclass, ".desktop", NULL);
   g_free (wmclass);
 
-  appsys = shell_app_system_get_default ();
   app = shell_app_system_lookup_heuristic_basename (appsys, with_desktop);
   g_free (with_desktop);
 
@@ -323,9 +323,7 @@ get_app_for_window_direct (MetaWindow  *window)
     }
 
   if (app == NULL)
-    {
-      app = _shell_app_new_for_window (window);
-    }
+    app = shell_app_system_get_app_for_window (appsys, window);
 
   return app;
 }